home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13593 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: uhura.phoenix.net!usenet
  2. From: brucew@phoenix.net (Bruce Wedding)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: accessing structures via pointers
  5. Date: Tue, 09 Apr 1996 03:50:52 GMT
  6. Organization: BranPaul Systems
  7. Message-ID: <4kcn32$564@uhura.phoenix.net>
  8. References: <1996Apr8.144012.25767@leeds.ac.uk>
  9. NNTP-Posting-Host: dial89.phoenix.net
  10. X-Newsreader: Moe's Newsreader    
  11.  
  12. In comp.lang.c
  13. csyamc@scs.leeds.ac.uk (A M Casey) wrote:
  14.  
  15. > struct group {
  16. >                 char    *gr_name;   /* the name of the group */
  17. >                 char    *gr_passwd; /* the encrypted group password */
  18. >                 gid_t   gr_gid;     /* the numerical group ID */
  19. >                 char    **gr_mem;   /* vector of pointers to member names */
  20. >          };
  21.  
  22. I assume the function is allocating memory for these strings?
  23.  
  24. >printf("the group name is %s\n",tempgroup.gr_name);
  25.  
  26. Try it like this:
  27.  
  28. printf("the group name is %s\n",tempgroup->gr_name);
  29.  
  30. which is an easier way than doing this:
  31.  
  32. printf("the group name is %s\n",*(tempgroup).gr_name);
  33.  
  34.  
  35.  
  36.  
  37.  
  38.